package com.aiyige.model.request;

import com.aiyige.base.api.ApiManager;
import com.aiyige.model.PlayProgressModel;

import okhttp3.ResponseBody;
import retrofit2.Call;

/**
 * 上传播放进度
 */
public class UploadPlayProgressRequest {
    private String resourceId;
    private int stage;
    private long progress;

    private UploadPlayProgressRequest(Builder builder) {
        setResourceId(builder.resourceId);
        setStage(builder.stage);
        setProgress(builder.progress);
    }

    public static Builder newBuilder() {
        return new Builder();
    }


    public String getResourceId() {
        return resourceId == null ? "" : resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public int getStage() {
        return stage;
    }

    public void setStage(int stage) {
        this.stage = stage;
    }

    public long getProgress() {
        return progress;
    }

    public void setProgress(long progress) {
        this.progress = progress;
    }

    public static final class Builder {
        private String resourceId;
        private int stage;
        private long progress;

        private Builder() {
        }

        public Builder resourceId(String resourceId) {
            this.resourceId = resourceId;
            return this;
        }

        public Builder stage(int stage) {
            this.stage = stage;
            return this;
        }

        public Builder progress(long progress) {
            this.progress = progress;
            return this;
        }

        public Call<ResponseBody> build() {
            return ApiManager.getService().videoCourseStudyProgresses(PlayProgressModel.newBuilder()
                    .resourceId(resourceId)
                    .stage(stage)
                    .progress(progress)
                    .build());
        }
    }
}
